<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>腾飞健康管理平台</title>
    <link rel="stylesheet" href="lib/layui/css/layui.css">
</head>
<body style="padding: 10px">
<form class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">检查名称</label>
        <div class="layui-input-block">
            <select name="examineName" lay-filter="examineItemId" lay-verify="required">
                <option value="">请选择</option>
                <option value="普通肠镜">普通肠镜</option>
                <option value="无痛肠镜">无痛肠镜</option>
                <option value="普通胃镜">普通胃镜</option>
                <option value="无痛胃镜">无痛胃镜</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">送检样本</label>
        <div class="layui-input-block">
            <select name="examineSample" lay-filter="examineItemId" lay-verify="">
                <option value="">请选择</option>
                <option value="回盲瓣">回盲瓣</option>
                <option value="直肠">直肠</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">适用性别</label>
        <div class="layui-input-block">
            <select name="applySex" lay-verify="required">
                <option value="">请选择</option>
                <option value="不限性别">不限性别</option>
                <option value="男性">男性</option>
                <option value="女性">女性</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">适用范围</label>
        <div class="layui-input-block">
            <select name="applyRange" lay-verify="required">
                <option value="">请选择</option>
                <option value="不限群体">不限群体</option>
                <option value="婴幼儿">婴幼儿</option>
                <option value="青少年">青少年</option>
                <option value="中年">中年</option>
                <option value="老年">老年</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block">
            <input type="text" name="price" autocomplete="off" placeholder="￥" class="layui-input"
                   lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitItem">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script type="text/javascript" src="lib/layui/layui.js"></script>
<script>
    layui.use(["form", "layer", "jquery"], function () {
        let form = layui.form;
        let layer = layui.layer;
        let $ = layui.jquery;

        form.on("submit(submitItem)", function (data) {
            console.log(data.field);
            $.ajax({
                url: "/submitAddSpeExamineItem",
                data: data.field,
                dataType: "json",
                tyep: "post",
                success: function (responseResult) {
                    let iconNum;
                    if (responseResult.code == 1) {
                        iconNum = 1;
                    } else {
                        iconNum = 2;
                    }
                    layer.msg(responseResult.msg, {
                        time: 1500,
                        icon: iconNum,
                    });
                },
                error: function () {
                    layer.msg("服务器错误！", {
                        icon: 2,
                        time: 1500,
                    });
                }
            });
            return false;
        });
    });

</script>
</body>
</html>